// Code generated by protoc-gen-validate. DO NOT EDIT.
// source: google/api/http.proto

package annotations

import (
	"bytes"
	"errors"
	"fmt"
	"net"
	"net/mail"
	"net/url"
	"regexp"
	"strings"
	"time"
	"unicode/utf8"

	"google.golang.org/protobuf/types/known/anypb"
)

// ensure the imports are used
var (
	_ = bytes.MinRead
	_ = errors.New("")
	_ = fmt.Print
	_ = utf8.UTFMax
	_ = (*regexp.Regexp)(nil)
	_ = (*strings.Reader)(nil)
	_ = net.IPv4len
	_ = time.Duration(0)
	_ = (*url.URL)(nil)
	_ = (*mail.Address)(nil)
	_ = anypb.Any{}
)

// Validate checks the field values on Http with the rules defined in the proto
// definition for this message. If any rules are violated, an error is returned.
func (m *Http) Validate() error {
	if m == nil {
		return nil
	}

	for idx, item := range m.GetRules() {
		_, _ = idx, item

		if v, ok := interface{}(item).(interface{ Validate() error }); ok {
			if err := v.Validate(); err != nil {
				return HttpValidationError{
					field:  fmt.Sprintf("Rules[%v]", idx),
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}

	}

	// no validation rules for FullyDecodeReservedExpansion

	return nil
}

// HttpValidationError is the validation error returned by Http.Validate if the
// designated constraints aren't met.
type HttpValidationError struct {
	field  string
	reason string
	cause  error
	key    bool
}

// Field function returns field value.
func (e HttpValidationError) Field() string { return e.field }

// Reason function returns reason value.
func (e HttpValidationError) Reason() string { return e.reason }

// Cause function returns cause value.
func (e HttpValidationError) Cause() error { return e.cause }

// Key function returns key value.
func (e HttpValidationError) Key() bool { return e.key }

// ErrorName returns error name.
func (e HttpValidationError) ErrorName() string { return "HttpValidationError" }

// Error satisfies the builtin error interface
func (e HttpValidationError) Error() string {
	cause := ""
	if e.cause != nil {
		cause = fmt.Sprintf(" | caused by: %v", e.cause)
	}

	key := ""
	if e.key {
		key = "key for "
	}

	return fmt.Sprintf(
		"invalid %sHttp.%s: %s%s",
		key,
		e.field,
		e.reason,
		cause)
}

var _ error = HttpValidationError{}

var _ interface {
	Field() string
	Reason() string
	Key() bool
	Cause() error
	ErrorName() string
} = HttpValidationError{}

// Validate checks the field values on HttpRule with the rules defined in the
// proto definition for this message. If any rules are violated, an error is returned.
func (m *HttpRule) Validate() error {
	if m == nil {
		return nil
	}

	// no validation rules for Selector

	// no validation rules for Body

	// no validation rules for ResponseBody

	for idx, item := range m.GetAdditionalBindings() {
		_, _ = idx, item

		if v, ok := interface{}(item).(interface{ Validate() error }); ok {
			if err := v.Validate(); err != nil {
				return HttpRuleValidationError{
					field:  fmt.Sprintf("AdditionalBindings[%v]", idx),
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}

	}

	switch m.Pattern.(type) {

	case *HttpRule_Get:
		// no validation rules for Get

	case *HttpRule_Put:
		// no validation rules for Put

	case *HttpRule_Post:
		// no validation rules for Post

	case *HttpRule_Delete:
		// no validation rules for Delete

	case *HttpRule_Patch:
		// no validation rules for Patch

	case *HttpRule_Custom:

		if v, ok := interface{}(m.GetCustom()).(interface{ Validate() error }); ok {
			if err := v.Validate(); err != nil {
				return HttpRuleValidationError{
					field:  "Custom",
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}

	}

	return nil
}

// HttpRuleValidationError is the validation error returned by
// HttpRule.Validate if the designated constraints aren't met.
type HttpRuleValidationError struct {
	field  string
	reason string
	cause  error
	key    bool
}

// Field function returns field value.
func (e HttpRuleValidationError) Field() string { return e.field }

// Reason function returns reason value.
func (e HttpRuleValidationError) Reason() string { return e.reason }

// Cause function returns cause value.
func (e HttpRuleValidationError) Cause() error { return e.cause }

// Key function returns key value.
func (e HttpRuleValidationError) Key() bool { return e.key }

// ErrorName returns error name.
func (e HttpRuleValidationError) ErrorName() string { return "HttpRuleValidationError" }

// Error satisfies the builtin error interface
func (e HttpRuleValidationError) Error() string {
	cause := ""
	if e.cause != nil {
		cause = fmt.Sprintf(" | caused by: %v", e.cause)
	}

	key := ""
	if e.key {
		key = "key for "
	}

	return fmt.Sprintf(
		"invalid %sHttpRule.%s: %s%s",
		key,
		e.field,
		e.reason,
		cause)
}

var _ error = HttpRuleValidationError{}

var _ interface {
	Field() string
	Reason() string
	Key() bool
	Cause() error
	ErrorName() string
} = HttpRuleValidationError{}

// Validate checks the field values on CustomHttpPattern with the rules defined
// in the proto definition for this message. If any rules are violated, an
// error is returned.
func (m *CustomHttpPattern) Validate() error {
	if m == nil {
		return nil
	}

	// no validation rules for Kind

	// no validation rules for Path

	return nil
}

// CustomHttpPatternValidationError is the validation error returned by
// CustomHttpPattern.Validate if the designated constraints aren't met.
type CustomHttpPatternValidationError struct {
	field  string
	reason string
	cause  error
	key    bool
}

// Field function returns field value.
func (e CustomHttpPatternValidationError) Field() string { return e.field }

// Reason function returns reason value.
func (e CustomHttpPatternValidationError) Reason() string { return e.reason }

// Cause function returns cause value.
func (e CustomHttpPatternValidationError) Cause() error { return e.cause }

// Key function returns key value.
func (e CustomHttpPatternValidationError) Key() bool { return e.key }

// ErrorName returns error name.
func (e CustomHttpPatternValidationError) ErrorName() string {
	return "CustomHttpPatternValidationError"
}

// Error satisfies the builtin error interface
func (e CustomHttpPatternValidationError) Error() string {
	cause := ""
	if e.cause != nil {
		cause = fmt.Sprintf(" | caused by: %v", e.cause)
	}

	key := ""
	if e.key {
		key = "key for "
	}

	return fmt.Sprintf(
		"invalid %sCustomHttpPattern.%s: %s%s",
		key,
		e.field,
		e.reason,
		cause)
}

var _ error = CustomHttpPatternValidationError{}

var _ interface {
	Field() string
	Reason() string
	Key() bool
	Cause() error
	ErrorName() string
} = CustomHttpPatternValidationError{}
